import requests
from Api.ihrmEmpManageApi import EmpMangeApi
from common.dbTools import DBTools
from common.assretTools import common_tools
from common.getHeader import get_header


class TestAddEmp(object):

    def setup_class(self):
        self.emp = EmpMangeApi()

        # 准备请求头

        self.req_header = get_header()

    def setup(self):
        DBTools.db_iud("delete from bs_user where mobile = '19933652415';")

    def teardown(self):
        DBTools.db_iud("delete from bs_user where mobile = '19933652415';")

    def test01_add_success(self):
        """添加员工成功"""
        req_body = {
            "username": "张三疯007",
            "mobile": "19933652415",
            "workNumber": "9527"
        }

        resp = self.emp.add_emp(self.req_header, req_body)
        print("添加成功：", resp.json())
        common_tools(resp, 200, True, 10000, "操作成功")

    def test02_mobile_none(self):
        """手机号为空"""
        req_body = {
            "username": "张三疯007",
            "mobile": None,
            "workNumber": "9527"
        }
        resp = self.emp.add_emp(self.req_header, req_body)
        print("手机号为空：", resp.json())
        common_tools(resp, 200, False, 20002, "新增员工失败")

    def test03_no_params(self):
        """无参"""
        req_body = None
        resp = self.emp.add_emp(self.req_header, req_body)
        print("无参：", resp.json())
        common_tools(resp, 200, False, 99999, "抱歉，系统繁忙，请稍后重试")
